package com.qf.mvc2203.controller;

import com.qf.mvc2203.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/user")
public class UserController {
    /**
     * 重定向到用户查询接口
     */
    @RequestMapping("/add")
    public String addUser(User user){
        System.out.println("UserController add");
        System.out.println(user);
        for (String s : user.getHobby()) {
            System.out.println(s);
        }
        return "redirect:list";
    }

    /**
     * 重定向到用户查询接口
     */
    @RequestMapping("/del/{id}")
    public String delUser(@PathVariable("id") Integer id){
        System.out.println("UserController del");
        System.out.println(id);
        return "redirect:list";
    }

    /**
     * 重定向到user.html页面
     */
    @RequestMapping("/list")
    public String listUser(){
        System.out.println("UserController list");
        return "redirect:/views/user.html";
    }
}
